FROM php:7.4.11-fpm as php74-fpm
# 切换源
# htts兼容命令
#RUN apt-get install -y apt install apt-transport-https ca-certificates
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak \
    && echo "deb http://mirrors.ustc.edu.cn/debian/ buster main" >>/etc/apt/sources.list \
    && echo "# deb-src http://mirrors.ustc.edu.cn/debian/ buster main" >>/etc/apt/sources.list \
    && echo "deb http://mirrors.ustc.edu.cn/debian-security buster/updates main" >>/etc/apt/sources.list \
    && echo "# deb-src http://mirrors.ustc.edu.cn/debian-security buster/updates main" >>/etc/apt/sources.list \
    && echo "deb http://mirrors.ustc.edu.cn/debian/ buster-updates main" >>/etc/apt/sources.list \
    && echo "# deb-src http://mirrors.ustc.edu.cn/debian/ buster-updates main" >>/etc/apt/sources.list\
    # MYSQL新增
    && echo "deb https://mirrors.ustc.edu.cn/debian unstable main contrib non-free" >>/etc/apt/sources.list \
    && echo "deb https://mirrors.ustc.edu.cn/debian experimental main contrib non-free" >>/etc/apt/sources.list

## 安装扩展
RUN apt-get update
RUN apt-get install -y libfreetype6-dev
RUN apt-get install -y libjpeg62-turbo-dev
RUN apt-get install -y libmcrypt-dev
RUN apt-get install -y libpng-dev
RUN apt-get install -y libjpeg-dev
RUN apt-get install -y build-essential
RUN apt-get install -y libmagickcore-dev
RUN apt-get install -y libmagickwand-dev
RUN apt-get install -y imagemagick
# M1 TODO
# RUN apt-get install -y libmpx2
# M1 TODO
RUN apt-get install -y mysql-client
RUN apt-get install -y zlib1g-dev
RUN apt-get install -y libzip-dev
# zlib1g-dev libzip-dev 安装ZIP
# docker-php-source extract | delete # 创建并初始化(删除) /usr/src/php目录(PHP扩展源码的存放目录)
RUN docker-php-source extract
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install -j$(nproc) iconv pdo_mysql mysqli bcmath calendar exif gettext sockets \
        dba pcntl shmop sysvmsg sysvsem sysvshm gd zip
# 分开安装
# M1 TODO
#RUN apt-get install -y gcc-8-base libgcc-8-dev
# M1 TODO
RUN apt-get install -y libc6-dev
# 安装自定义插件 pecl: https://pecl.php.net/package-search.php
RUN apt-get install -y libmagickwand-dev g++ libssl-dev build-essential zlibc  libidn11-dev libidn11
RUN pecl install mcrypt \
    && pecl install imagick \
    && pecl install redis-3.1.6 \
    && pecl install xlswriter-1.3.6 \
    && pecl install xhprof-2.2.2 \
    && pecl install swoole-4.5.9 \
    && pecl install xdebug-2.9.8 \
    && docker-php-ext-enable mcrypt imagick redis xlswriter xhprof swoole
# 安装易用扩展
RUN apt-get install -y vim sudo less git zip unzip lrzsz net-tools wget iputils-ping graphviz
# 安装PHP composer
RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && sudo mv composer.phar /usr/local/bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
    && composer global require laravel/installer \
    && echo "alias laravel='~/.composer/vendor/bin/laravel'" >>~/.bashrc
    #laravel 安装器 #composer global update #laravel -V #laravel new blog
# 旧版本composer
#COPY ./composer.phar /usr/local/bin/composer
#RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# 自定义服务
RUN echo "export LS_OPTIONS='--color=auto'" >>~/.bashrc
RUN echo "eval "`dircolors`"" >>~/.bashrc
RUN echo "alias ll='ls \$LS_OPTIONS -l'" >>~/.bashrc
RUN ln -sfn /var/www /root/www \
    && ln -sfn /var/log /root/log